<?php 
$cs=Yii::app()->clientScript;
$cs->registerCssFile(Yii::app()->baseUrl.'/css/common.css');
$cs->registerScript('product_admin',<<<END
$("#sel_all").toggle(
function(){
	$(this).val('全否');
	$("input[type=checkbox]").attr("checked",true);
},
function(){
	$(this).val('全选');
	$("input[type=checkbox]").attr("checked",false);
}
);
$("form:eq(1)").submit(
function(){
	if($("input[type=checkbox]:checked").length==0){alert("请选择要删除的信息!");return false;}
	return confirm('确定要删除已选中信息吗？');
});
END
);
?>
<h2>产品管理</h2>
<?php echo CHtml::beginForm(array('product_admin'),'post');?>
审核/未审核：<?php echo CHtml::dropDownList('keys[product.state]', isset($_GET['keys']['product.state'])?$_GET['keys']['product.state']:'', array(''=>'全部','0'=>'审核','2'=>'未审核'));?>
产品名称：<input type="text" name="keys[product.name]" size="7" value="<?php echo isset($_GET['keys']['product.name'])?$_GET['keys']['product.name']:'';?>"/>
厂商名称：<input type="text" name="keys[business.name]" size="7" value="<?php echo isset($_GET['keys']['business.name'])?$_GET['keys']['business.name']:'';?>"/>
厂商品牌：<input type="text" name="keys[business.brand]" size="7" value="<?php echo isset($_GET['keys']['business.brand'])?$_GET['keys']['business.brand']:'';?>"/>
模糊查询：<?php echo CHtml::radioButtonList('keys[blur]',isset($_GET['keys']['blur'])?$_GET['keys']['blur']:'1', array('1'=>'是','0'=>'否'),array('separator'=>''));?>
<input type="submit" value="搜索"/>
<?php echo CHtml::endForm();?>
<?php echo CHtml::beginForm(array('set_product_state')+$_GET,'post');?>
<input id="sel_all" type="button" value="全选"/><input type="submit" value="删除选中"/>
<table class="dataGrid" width="1090">
  <thead>
  <tr>
  	<th width="30">选择</th>
    <th width="150"><?php echo $sort->link('name'); ?></th>
    <th width="150"><?php echo $sort->link('business_name'); ?></th>
    <th width="50"><?php echo $sort->link('business_brand'); ?></th>
    <th width="150"><?php echo $sort->link('logo'); ?></th>
    <th width="50"><?php echo $sort->link('series_name'); ?></th>
    <th width="100"><?php echo $sort->link('type'); ?></th>
    <th width="100"><?php echo $sort->link('standards'); ?></th>
    <th width="80"><?php echo $sort->link('material'); ?></th>
    <th width="40"><?php echo $sort->link('state'); ?></th>
    <th width="70"><?php echo $sort->link('update_time'); ?></th>
	<th width="120">操作</th>
  </tr>
  </thead>
  <tbody>
<?php foreach($models as $n=>$model): ?>
  <tr class="<?php echo $n%2?'even':'odd';?>">
  	<td><input type="checkbox" name="ids[]" value="<?php echo $model->id;?>"/></td>
  	<?php $url=array('product/get_product','id'=>$model->id);?>
    <td><?php echo CHtml::link($model->name,$url,array('target'=>'_blank')); ?></td>
    <?php $url1=array('business/get_business','id'=>$model->fk_business_id);?>
    <td><?php echo CHtml::link($model->business_name,$url1,array('target'=>'_blank')); ?></td>
    <td><?php echo CHtml::encode($model->business_brand); ?></td>
    <td><img src="<?php echo $model->logo;?>" width="128" height="60" /></td>
    <td><?php echo CHtml::encode($model->series_name); ?></td>
    <td><?php echo CHtml::encode($model->type); ?></td>
    <td><?php echo CHtml::encode($model->standards); ?></td>
    <td><?php echo CHtml::encode($model->material); ?></td>
    <td><?php echo CHtml::encode($model->state==0?'审核':'未审核'); ?></td>
    <td><?php echo CHtml::encode($model->update_time); ?></td>
    <td>
     <?php echo CHtml::link('审核',array('set_product_state','id'=>$model->id,'state'=>0)+$_GET); ?>
      <?php echo CHtml::link('未审核',array('set_product_state','id'=>$model->id,'state'=>2)+$_GET); ?>
     <?php echo CHtml::link('删除',array('set_product_state','id'=>$model->id,'state'=>1)+$_GET,array('confirm'=>"确定要删除 {$model->name} 的产品信息吗？")); ?>
    </td>
  </tr>
<?php endforeach; ?>
  </tbody>
</table>
</form>
<br/>
<?php $this->widget('CLinkPager',array('pages'=>$pages,'htmlOptions'=>array('style'=>'width:900px;'))); ?>